package com.course.serviceImpl;

import com.course.daoI.ProfileDAOI;
import com.course.daoImpl.ProfileDAOImpl;
import com.course.exception.ConnectionException;
import com.course.exception.DataNotFoundException;
import com.course.exception.LoginException;
import com.course.formbean.ProfileFormBean;
import com.course.serviceI.ProfileServiceI;
import com.course.util.CoreHash;

public class ProfileServiceImpl implements ProfileServiceI{

	
	ProfileDAOI pdao=new ProfileDAOImpl();
	
	boolean flag=false;
	ProfileFormBean pfb=null;
	CoreHash ch=null;
	
	public boolean changeAccountStatus(String loginid, int status)
			throws LoginException, ConnectionException {
		
		  
		flag=pdao.changeAccountStatus(loginid, status);
		if(flag==false)
		{
			throw new ConnectionException();
			}
       else if(loginid==null) {
			throw new LoginException();
			}
		return flag;
		
	}

	public ProfileFormBean getProfile(String loginname, String path)
			throws DataNotFoundException {
	 
		
		pfb=pdao.getProfile(loginname, path);
        if (pfb==null) {
			
			throw new DataNotFoundException();
			
		   }
		      return pfb;
		
	}

	public CoreHash getReportFromTo(String sdate, String edate) throws DataNotFoundException{
		
		ch=pdao.getReportFromTo(sdate, edate);
            if (ch==null) {
			
			throw new DataNotFoundException();
			
		   }
		      return ch;
	}

	public CoreHash getReportPresent() throws DataNotFoundException {
		
		
		ch=pdao.getReportPresent();
        if (ch==null) {
		
		throw new DataNotFoundException();
		
	   }
	      return ch;
		
	}

	public boolean modifyProfile(ProfileFormBean regbean)
			throws LoginException, ConnectionException {
		
		
		flag=pdao.modifyProfile(regbean);
		
		if (flag==false) {
			
			throw new ConnectionException();
			} else if(regbean==null) {
			throw new LoginException();
			}
		      return flag;
		
		
		
	}

	public boolean registration(ProfileFormBean regbean) throws LoginException,
			ConnectionException {
		
		flag=pdao.registration(regbean);
		
             if (flag==false) {
			
			throw new ConnectionException();
			} else if(regbean==null) {
			throw new LoginException();
			}
		      return flag;
		
	}

}
